import 'package:safetymonitor/app/core/core.dart';

///风险承诺dialog视图
class CustomGeneralCallbackDialog extends StatelessWidget {
  const CustomGeneralCallbackDialog({
    required this.content,
    required this.onPressed,
    this.contentString,
    this.title = '提示',
    super.key,
  });

  final VoidCallback onPressed;

  // 标题
  final String title;

  final Widget? content;
  final String? contentString;

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      child: Container(
        width: 300.w,
        height: 210.w,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(20.w)),
          gradient: const LinearGradient(
              //渐变位置
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
              //渐变颜色[始点颜色, 结束颜色]
              colors: [
                Color(0xffE7EAFF),
                Color(0xffffffff),
                Color(0xffffffff),
                Color(0xffffffff),
              ]),
        ),
        child: Stack(
          alignment: Alignment.center,
          children: [
            Container(
                padding: EdgeInsets.symmetric(horizontal: 30.w),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: [
                    Text(
                      title,
                      style: TextStyle(
                          color: Colors.black,
                          fontSize: 18.sp,
                          fontWeight: FontWeight.bold),
                    ),
                    content ??
                        Text(
                          '$contentString',
                          style: TextStyle(
                            color: Colors.black,
                            fontSize: 14.sp,
                          ),
                        ),
                    Column(
                      children: [
                        SizedBox(
                          width: 270.w,
                          height: 40.w,
                          child: ElevatedButton(
                            style: ButtonStyle(
                              backgroundColor: MaterialStateProperty.all(
                                  const Color(0xff5C6DFF)),
                            ),
                            onPressed: onPressed,
                            child: Text(
                              '确定',
                              style: TextStyle(
                                  fontSize: 16.sp, color: Colors.white),
                            ),
                          ),
                        ),
                        Text(
                          '请上传 大小不超过10MB的文件',
                          style: TextStyle(
                            color: Colors.black,
                            fontSize: 14.sp,
                          ),
                        ),
                      ],
                    )
                  ],
                )),
            Positioned(
                top: 0,
                right: 0,
                child: IconButton(
                  icon: Container(
                    width: 30.w,
                    height: 30.w,
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(15.w)),
                    ),
                    child: Icon(
                      Icons.close,
                      color: Colors.grey,
                      size: 21.w,
                    ),
                  ),
                  onPressed: () {
                    Get.back(result: false);
                  },
                ))
          ],
        ),
      ),
    );
  }
}
